package com.ycm.enums;

/**
 * 证件类型枚举
 *
 * @author ycm
 * @date 2024-11-13
 */
public enum IdCardType implements BaseEnum {
    /**
     * 身份证
     */
    ID_CARD(1, "身份证"),
    /**
     * 护照
     */
    PASSPORT(2, "护照"),
    /**
     * 其他
     */
    OTHER(3, "其他");

    private final Integer code;
    private final String description;

    IdCardType(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    public Integer getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static IdCardType fromCode(Integer code) {
        for (IdCardType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("错误的类型 ： " + code);

    }

    @Override
    public Integer getValue() {
        return this.getCode();
    }

    @Override
    public String desc() {
        return description;
    }
}
